<!DOCTYPE html>
<html>

<head>
    <title>a.1</title>

    <style type="text/css">
        div {
            padding: 10px;
        }
    </style>
</head>

<body>
    <div id="div_url"></div>
    <hr />
    <div>
        <input type="text" id="i_title" value="修改标题后的a.1" />&nbsp;&nbsp;
        <a id="a_change_title" href="javascript:;">修改标题</a>
    </div>
    <hr />
    <div>
        <textarea id="ta_get_data" style="width:500px;">{ id1: '#id1', id2: '#id2', var1: 'var' }</textarea><br />
        <a href="javascript:;" id="a_get_data">获取opener的数据：</a><br />
        jqxt.getOpenerData('a', { id1: '#id1', id2: '#id2', var1: 'var' }, function (data) {<br />
        &nbsp;&nbsp;&nbsp;&nbsp;jqxt.logLine('a.2 getOpenerData');<br />
        &nbsp;&nbsp;&nbsp;&nbsp;jqxt.log(data);<br />
        &nbsp;&nbsp;&nbsp;&nbsp;jqxt.logLine();<br />
        });<br />
        结果：<span id="span_data_result"></span>
    </div>
    <hr />
    <div>
        <textarea id="ta_exec_data"
            style="width:500px;">1, '2', [3, 4], { a: 5, b: '6', c: [7, 8], d: { e: 9, f: '10' } }</textarea><br />
        <a href="javascript:;" id="a_exec_data">执行opener的函数：</a><br />
        jqxt.execOpenerFunc('func', 1, '2', [3, 4], { a: 5, b: '6', c: [7, 8], d: { e: 9, f: '10' } });<br />
        结果请查看opener页面
    </div>
    <script src="https://cdn.bootcdn.net/npm/jquery@2.1.4/dist/jquery.min.js"></script>
    <script>
        $(document).ready(function () {
            $('#div_url').html(window.location.href);
            $('#a_change_title').on('click', function () {
                jqxt.changeTitle($('#i_title').val());
            });
            $('#a_get_data').on('click', function () {
                var data = null;
                try {
                    data = eval('(' + $('#ta_get_data').val() + ')');
                } catch (e) {
                    alert('获取opener的数据时传入的参数不正确');
                }
                if (!data) {
                    return;
                }
                jqxt.getOpenerData('a', data, function (data) {
                    $('#span_data_result').html(jqxt.dataToStr(data));
                });
            });
            $('#a_exec_data').on('click', function () {
                try {
                    eval("jqxt.execOpenerFunc('func', " + $('#ta_exec_data').val() + ")");
                } catch (e) {
                    alert('执行opener的函数时传入的参数不正确');
                }
            });
        });
    </script>
</body>

</html>